Writing Formulas

The Payroll system has the ability to use formulas to calculate deductions, employer costs, local withholdings, and employer taxes based on earnings and tables. You can use Variables for numbers such as year-to-date amounts, gross earnings, and so on, which you can manipulate using Methods, Operations, and Functions, much like a spreadsheet program. You can also look up tax rates and other variable factors in formula tables.

The Payroll system uses formulas to calculate deductions and withholdings based on earnings and tables. These formulas involve variables, constants, operations, and functions.

  • Commands are functions that tell the formula what to do to retrieve a value.
  • Variables are an equivalent that stand for something which can change value as other actions occur. There are numeric, as well as text, variables.
  • Constants are positive or negative numbers.
  • Factors are a constant defined in a formula or in an employee or employer override factor. You can set up to six factors in each formula. Employee and employer formulas have up to six override factors.
  • Functions you can use three types of functions when constructing formulas: Table Lookups, Conditionals, and MIN/MAX functions.
  • Operations proceed according to standard mathematical rules. Multiplication and division are first performed. Addition and subtraction are performed afterwards. Functions within parentheses are performed before operations outside of parenthesis.

You can use positive or negative numbers (constants) in formulas. You can also use these variable which store payroll information values set by the Payroll system as it calculates the employee’s paycheck:

Traverse uses Iron Python scripting for the scripting language to write the formulas. There are many books available as references to use when writing scripts. A summary of valid variables, operations, and functions follow. If you are new to formulas or you need to review them, several examples of formulas are available in this section.

Formula Tips

  • When setting up your formulas, you don’t need to type all the commands and variables into the formula. With the formula box open you can double click on the command and variable in the right column to bring the value double clicked on into the formula, and then add quotation marks and other text to the formula manually. The value double clicked on will be brought into the formula at the point of the cursor.
  • If your formula might result in a negative amount calculated use a line at the end of the formula similar to this:

    if L3 < 0:

       L4 = 0

    else:

       L4 = L3

    This formula line says if line 3 is less than zero then return 0 or else return the value from line 3.

  • If you are going to be using variable amounts that could change for each employee, use the factor fields and use the (“FCx”) function (x being the value 1 to 6 corresponding to the factor fields).
  • When using the conditional if: else: make sure to put a colon after the if statement and after the else command. When defining the then, the line after the if, and when defining the else, the line after the else, be consistent with the number of spaces used to indent the conditional values. In this sample above, 3 spaces are used for each of the if, then, else conditional statements.
  • When using the #tax methods commands, the variable and factors must be enclosed in quotation marks within the parentheses (“ADJEARN”).
  • When bringing in line number values into another line the line numbers are not enclosed in parentheses or quotation marks. For example: L9 = L6 - L8
  • Line numbers can be defined in many different ways within the formulas. The line number is defined by putting an equal sign after the value you want to use for the line number. For example: L1 = would be defining line 1. y1 = would also be defining line 1 but using the y as a reference. When only one line is used you can use a character reference such as res = to define the line number as the result.
  • The last line in each formula must contain the f.SetNumericVariable command to return the value calculated. For example: f.SetNumericVariable(“CALCVALUE”, L4) is saying set the numeric variable to the calculated value from line 4, which is the last line defined in the formula.

Back to top of page

Formula Examples

The following examples demonstrate how to use different functions in the Payroll system to set up deductions calculated by formulas. There is more than one way to set up these deductions to calculate correctly. The setups used in the examples are chosen to give you an overview of how the different functions in the Payroll system can work together to calculate deductions.

When the system calculates deductions, deductions set up to be calculated on gross pay in the Deductions/Employer Costs function on the Code Maintenance menu. Deductions are calculated first in the order of the sequence number for the pay period in the Deductions tab in the Employee Information function.

After the gross pay deductions are calculated, the withholdings are calculated.

Deductions set up to be calculated on net pay are deducted last and are deducted in the reverse order of the sequence number on the deductions tab. For Example: If the pay check was not large enough to have all the withholdings and deductions taken out and have an amount to print on the check, the deduction calculation will look to the deduction setup for the employee and remove the deduction with the largest sequence number. If the check now has enough to cover the withholdings and deductions it will print a check for 0 dollars and not include the stock plan as a deduction.

If a garnished deduction must be calculated after certain other deductions are taken, then the deductions that can be taken prior to the garnishment deduction should be set up as gross pay deductions. Set up the garnishment deduction as a net pay deduction.

If there are deductions that can be calculated after the garnishment is deducted, they should be set up as calculated on net pay and should have a sequence number larger than the garnishment deduction in the Scheduled Deduction section of the Employee Information screen on the Deductions tab.

 

Back to top of page